package com.example.taximeter.service.impl;

import com.example.taximeter.bean.FileInfo;
import com.example.taximeter.mapper.FileInfoMapper;
import com.example.taximeter.service.FileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文件管理
 */
@Service
public class FileInfoServiceImpl implements FileInfoService {

    private FileInfoMapper fileInfoMapper;

    @Autowired
    public FileInfoServiceImpl(FileInfoMapper fileInfoMapper){
        this.fileInfoMapper = fileInfoMapper;
    }



    @Override
    public List<FileInfo> findfileByOwnerid(String ownerid) {
        return fileInfoMapper.findfileByOwnerid(ownerid);
    }

    @Override
    public FileInfo findfileByFileid(String fileid) {
        return fileInfoMapper.findfileByFileid(fileid);
    }

    @Override
    public String createFile(FileInfo fileInfo) {
        if(fileInfoMapper.createFile(fileInfo)){
            return "成功";
        }else {
            return "失败";
        }
    }

    @Override
    public String updateFile(FileInfo fileInfo) {
        if(fileInfoMapper.updateFile(fileInfo)){
            return "成功";
        }else {
            return "失败";
        }
    }

    @Override
    public String deleteFile(String fileid) {
        if(fileInfoMapper.deleteFile(fileid)){
            return "成功";
        }else {
            return "失败";
        }
    }

    @Override
    public String updateFilecon(String fileid, byte[] data){
        if(fileInfoMapper.updateFileinfoByFileid(fileid,data)){
            return "成功";
        }else {
            return "失败";
        }
    }

    @Override
    public List<FileInfo> findFileInfos() {
        return fileInfoMapper.findfileinfo();
    }
}

